package com.piece.core.verifycode.factory.sms;

import com.piece.core.framework.constant.ParamConstants;
import com.piece.core.verifycode.factory.ValidateCode;
import com.piece.core.verifycode.processor.AbstractValidateCodeProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 短信验证码处理器
 */
@Component("smsValidateCodeProcessor")
public class SmsValidateCodeProcessor extends AbstractValidateCodeProcessor<ValidateCode> {

    @Autowired(required = false)
    private SmsValidateCodeService smsValidateCodeService;

    @Override
    public void send(HttpServletRequest request, HttpServletResponse response, ValidateCode validateCode) {
        String mobile = request.getParameter(ParamConstants.MOBILE);
        if (null != smsValidateCodeService)
            smsValidateCodeService.doSend(mobile, validateCode.getCode());
    }
}
